<%@page import="myJDBC.lowLevel.ObjectTypes"%>
<%@page import="myJDBC.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
<%@include file="smallJsps/styles.jsp" %>
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Objects</title>
<%@include file="smallJsps/bootstrapInclude.jsp" %>
</head>
<body>
<%@include file="smallJsps/logoutButton.jsp" %>
<%@include file="smallJsps/checkAdmin.jsp" %>
	<div class="row-fluid">
		<div class="span6 offset2">
<form action="showObjectTypes" name="form" method="GET">
		<select name="sel" onchange="submit()">
		<%
			int objid= -1;
			if(request.getParameter("sel")!=null)
				objid=Integer.parseInt(request.getParameter("sel"));
			ArrayList<String> listWithObjecttypes = new ArrayList<String>();
			listWithObjecttypes = ObjectTypes.returnObjectTypes();
			for (int i = 0; i < listWithObjecttypes.size(); i = i + 3) {						
				out.print("<option ");
				if(Integer.parseInt(listWithObjecttypes.get(i))==objid)
					 out.print("selected");
				out.println(" value="+listWithObjecttypes.get(i)+">" + listWithObjecttypes.get(i+1)+" || par="+listWithObjecttypes.get(i + 2)+ "</option>");
			}
		%>
		</select>
</form>
		<%
			if(objid != -1){
				objid=Integer.parseInt(request.getParameter("sel"));
				ArrayList<String> listWithAttributes2 = ObjectTypes.returnObjectType(objid);
				int barier= listWithAttributes2.indexOf(null);
				out.println("<h3> object type id="+listWithAttributes2.get(0)+"</h3>");
				out.println("<h3> object type name="+listWithAttributes2.get(1)+"</h3>");
		%>
			<table class="table-striped table-condensed" border="1">
				<tr><th>parents</th></tr>
				<%
					for (int i = 2; i < barier; i++) 
						out.println("<tr><td>" + listWithAttributes2.get(i) + "</td></tr>");
				 %>
			</table>
			<table class="table-striped table-condensed" border="3">
				<tr>
					<th>attribute_id</th>
					<th>name</th>
					<th>type</th>
				</tr>
		<%
			for (int i =barier+1; i < listWithAttributes2.size(); i = i + 3) {
				out.println("<tr><td>" + listWithAttributes2.get(i)
						+ "</td><td>" + listWithAttributes2.get(i + 1)
						+ "</td><td>" + listWithAttributes2.get(i + 2)
						+ "</td></tr>");
			}
			}
		%>	
			</table>
			<form method="get" action="privateOffice"><button class="btn" type="submit">privateOffice</button></form>
			</div>
			</div>
</body>
</html>